﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

namespace GPCSC.Web.sjs
{
    public partial class dybgV : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string ids = Usual.f_querystringToString("ids");
            f_fristLoad(ids);
        }
        protected void f_fristLoad(string PrimaryKey)
        {
            base.o_uiTable.Clear();
            SqlReadXml org = new SqlReadXml();
            base.o_uiTable.Add("@tabids", PrimaryKey);
            base.m_uiDataSet = org.ReaderDataSet("sel_dybg_one", base.o_uiTable);
            if (base.m_uiDataSet.Tables.Count > 0)
            {
                if (base.m_uiDataSet.Tables[0].Rows.Count > 0)
                {
                    //UIFactory set UI controls value:界面工厂设置界面控件值
                    try
                    {
                        base.m_uiDataSet.Tables[0].Rows[0]["dybg"] = base.m_uiDataSet.Tables[0].Rows[0]["dybg"].ToString().Replace("^", "\n");
                        base.o_uiTable = UIFactory.UIFactory_Set(this, base.m_uiDataSet.Tables[0]);

                    }
                    catch
                    {

                    }
                    //this.tes1.Value = base.m_uiDataSet.Tables[0].Rows[0]["hdtitile"].ToString();
                    //your can do databind yourself:对界面工厂不能填充的数据，通过ODRM手动填充
                }
            }
        }
        protected void LCallBack_Callback(object sender, NickLee.Web.UI.CallBackEventArgs e)
        {
            try
            {
                string ids = Usual.f_querystringToString("ids");
                Hashtable htable = new Hashtable();
                htable.Add("iscz", "1");
                SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();
                dtable.databyhtables(htable, "update", "FK_DY", "tabid", ids);

            }
            catch
            {

            }
            finally
            {
                LPanel.RenderControl(e.Output);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Clear();
            Response.BufferOutput = true;
            //设定输出的字符集
            Response.Charset = "GB2312";
            //假定导出的文件名为FileName.doc
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode("调研报告.doc"));
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            /**/
            ////设置导出文件的格式
            Response.ContentType = "application/ms-word";
            //关闭ViewState


            // GrwResult.EnableViewState = false;
            grid.EnableViewState = false;


            System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("ZH-CN", true);
            System.IO.StringWriter stringWriter = new System.IO.StringWriter(cultureInfo);
            System.Web.UI.HtmlTextWriter textWriter = new System.Web.UI.HtmlTextWriter(stringWriter);

            grid.RenderControl(textWriter);
            Response.Write(stringWriter.ToString());
            Response.End();
        }
    }
}